	//the number of items displayed once
	var display_count=3;
	//twitter account name
	var twitter_username="wwf_uk";
	//the number of items fetched in one request
	var fetch_count=10;
	//animation interval time(sec)
	var interval_sec=3;

	var current_index=-1;
	var arr_twitters=new Array();
	var url="http://twitter.com/status/user_timeline/"+twitter_username+".json?count="+fetch_count+"&callback=?";

    function call_twitter(){
		//alert(url);
		$.getJSON(url,function(data){
					$.each(data, function(i, item){
						//alert(item.user["profile_image_url"]);
						$("img#profile").attr("src",item.user["profile_image_url"]);
						var status = item.text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
									  return '<a href="'+url+'">'+url+'</a>';
									}).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
									  return  reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>';
						});

						var twitter_item ='<li class="t_status"><span>'+status+'</span><br/>'+'<a style="font-size:85%" href="http://twitter.com/'+twitter_username+'/statuses/'+item.id+'">'+relative_time(item.created_at)+'</a><a style="font-size:85%" href="http://twitter.com/?status=@'+twitter_username+'%20&in_reply_to_status_id='+item.id+'&in_reply_to='+twitter_username+'">Reply</a></li>';

						//alert(twitter_item);
						arr_twitters.push(twitter_item);
					});
				});
		$("#twitter_update_list").css(cssul);
	}


	function relative_time(time_value){
		    var values = time_value.split(" ");
		    time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
		    var parsed_date = Date.parse(time_value);
		    var relative_to = (arguments.length > 1)?arguments[1]:new Date();
		    var delta = parseInt((relative_to.getTime()-parsed_date)/1000);
		    delta = delta + (relative_to.getTimezoneOffset() * 60);

		    var r = '';
		    if (delta < 60) {
		        r = 'a minute ago';
		    } else if (delta < 120) {
		        r = 'couple of minutes ago';
		    } else if (delta < (45 * 60)) {
		        r = (parseInt(delta / 60)).toString() + ' minutes ago';
		    } else if (delta < (90 * 60)) {
		        r = 'an hour ago';
		    } else if (delta < (24 * 60 * 60)) {
		        r = '' + (parseInt(delta / 3600)).toString() + ' hours ago';
		    } else if (delta < (48 * 60 * 60)) {
		        r = '1 day ago';
		    } else {
		        r = (parseInt(delta / 86400)).toString() + ' days ago';
		    }

		    return r;
	}


	//ul element style setting function
	var cssul = {
	    'margin': 'auto',
	    'width': '272px',
	    'border-bottom':' 1px solid green',
	    'padding':'0px'
	};

	//li element style setting function
	var cssli = {'background':'#ffffff',
	    'border-color':'green',
	    'border-width':' 1px 1px 0',
	    'border-style':'solid solid none',
	    'margin':' 0 0',
	    'padding': '7px 7px 10px 14px'
	};

	//show limited items in the twitter statuses array
	function li_animate(){
		var old_index = current_index;

	  	if((old_index+1)<arr_twitters.length){
		  	if(arr_twitters[old_index+1-display_count]){arr_twitters[old_index+1-display_count] = "";}
		  	$("#twitter_update_list").prepend(arr_twitters[old_index+1]);
		  	$("#twitter_update_list >li").css(cssli);
	  		if($("li.t_status:eq("+display_count+")")){
				$("li.t_status:eq("+display_count+")").fadeOut(500, function(){$("li.t_status:eq("+display_count+")").remove();});
			}
			current_index = old_index+1;
	  	}
	  	else{
	  		//call_twitter();
	 	}
		//$(".t_status").css(cssul);
	  	setTimeout(li_animate, interval_sec*1000);
	}

